package com.wehealth.adapter;

import java.util.List;

import com.wehealth.R;
import com.wehealth.dm.DM_Questionnaire_page2_item;
import com.wehealth.dm.DM_ReportHealthResult;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TextView;

public class Adapter_ReportHealthResult extends BaseAdapter{
	
	private Context ctx;
	private List<DM_ReportHealthResult> mList;
    private int[] mProgress = new int[7];
    private int mIconWidth;
    private int mIconHeight;
	
	public Adapter_ReportHealthResult(Context context,List<DM_ReportHealthResult> mList){
		ctx =context;
		this.mList =mList;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mList.size();
	}

	@Override
	public Object getItem(int pos) {
		// TODO Auto-generated method stub
		return pos;
	}

	@Override
	public long getItemId(int pos) {
		// TODO Auto-generated method stub
		return pos;
	}

	@Override
	public View getView(int pos, View arg1, ViewGroup arg2) {
		// TODO Auto-generated method stub
		View view = LayoutInflater.from(ctx).inflate(R.layout.reporthealthresult,null);
		
		TextView title =(TextView)view.findViewById(R.id.result_title);
		TextView titleEx =(TextView)view.findViewById(R.id.result_title_ex);
		
		title.setText(mList.get(pos).getResult_title());
		titleEx.setText(mList.get(pos).getResult_titleEx());
		
		
		
		
		
		
		
		return view;
	}
	
	
	
    private Bitmap makeReportBitmapIcon(Drawable bgDrawable) {
        
        //mIconWidth = reportView.getWidth();
        //mIconHeight = reportView.getHeight();
       Log.d("SIMMON","mIconHeight="+mIconHeight);
       Log.d("SIMMON","mIconWidth = "+mIconWidth);
       Bitmap b = Bitmap.createBitmap(Math.max(mIconWidth, 1),
               Math.max(mIconHeight, 1),
               Bitmap.Config.ARGB_8888);
       Canvas canvas = new Canvas(b);
       canvas.drawColor(Color.WHITE);
       bgDrawable.setBounds(0, 0, b.getWidth(), b.getHeight());
       bgDrawable.draw(canvas);

       
       PaintDrawPath(canvas); 

       return b;
   }
   
   
   private void PaintDrawPath(Canvas canvas){
       Paint paint = new Paint();
       paint.setColor(Color.RED);
       paint.setStrokeWidth(5);
       
       float startX,startY;
       startX = (float) (mIconWidth*32/155.0);
       startY = (float) (mIconHeight * (23.5/142));
       float mgapX = (float) (mIconWidth *16.5/155.0);
       float mgapY = (float) (mIconHeight * 9.5/142);
       
       float[] x = new float[7];
       float[] y = new float[7];
       
       for(int i = 0; i < 7;i++){
           x[i] = startX+mgapX*i;
       }
       for(int j =0 ; j<7;j++){    
           float length = (float) (mProgress[j]/100.0);
           y[j] = startY +(float) (1-(float) (mProgress[j]/100.0)) * mgapY*7;

       }
       
       for(int n=0;n<6;n++){  
       canvas.drawLine(x[n], y[n],x[n+1], y[n+1], paint);
       }

   }
   
	
	

}
